﻿@model IList<FastFood.Core.Models.RestaurantModel>
@using FastFood.Front.Models

<h2>@ViewBag.PageTitle</h2>

@if (Model.Count == 0)
{
    <h3>@ViewBag.NoRestaurants</h3>
}
else
{
<table>
    <tr>
        <th>
            Restaurant name
        </th>
        <th>
            Restaurant description
        </th>
        <th>
            Restaurant location
        </th>
        <th></th>
    </tr>
    
    @foreach (var item in Model)
    {
    <tr>
        <td>
            @item.Name
        </td>
        <td>
            @item.Description
        </td>        
        <td>
            @if(String.IsNullOrWhiteSpace(item.Address.DependentLocalityName))
            {
                <text>Unknown(?)</text>
            }
            else
            {
                @item.Address.DependentLocalityName
            }
        </td>
        <td>            
            @Html.ActionLink("Make an order", "Make", new { controller = "Order", restaurantName = item.Name })
            | @Html.ActionLink("Details", "Details", new { name = item.Name })
        </td>
    </tr>
    }

</table>
}

@if (ViewBag.ListType != RestaurantListType.All)
{
<p>
    @Html.ActionLink("View all restaurants", "All", new { controller = "Restaurant" })
</p>
}

<script>
    $(document).ready(function () {
        $("#restaurants").addClass("active");
    });
</script>
